import java.util.ArrayList;

public class PhoneTest {
    public static void main(String[] args) {
        ArrayList<Phone>list =new ArrayList<>();
        Phone p1=new Phone("小米",1999);
        Phone p2=new Phone("苹果",7999);
        Phone p3=new Phone("红米",999);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        ArrayList<Phone> list1=check(list);
        for (int i = 0; i <list1.size() ; i++) {
            System.out.println(list1.get(i).getName()+","+list1.get(i).getPrice());
        }
    }

    public static ArrayList<Phone> check(ArrayList<Phone> list){
        ArrayList<Phone> phones=new ArrayList<>();
        for (int i = 0; i <list.size() ; i++) {
            if(list.get(i).getPrice()<2000){
                phones.add(list.get(i));
            }
        }
        return phones;
    }
}
